<template>
    <Card :bordered="false" dis-hover>
        <jgsearch :searchData="searchData" @on-enter="askDatasearch" @on-clear="askDatasearch" @click="askDataclick"
            @on-change-change="askDatachanges" @on-change-changes="askDatachange" @on-change-changess="askDatachangess"
            @click-subclick="subclick">
            <template slot="select">
                <Select @on-change="askDatachangeing" placeholder="请选择上次归属人" clearable v-model="params.belong_member_id">
                    <OptionGroup :label="item.label" v-for="item in member_list_list" :key="item.label">
                        <Option v-for="its in item.children" :value="its.value" :key="its.value">{{ its.label }}
                        </Option>
                    </OptionGroup>
                </Select>
            </template>
            <template v-slot:tag>
                <tags @sunchangetag="sunchangetag" :tags_ids="params.tags_ids" :project_tags_ids="params.project_tags_ids"/>
            </template>
            <template v-slot:addcheck>
                <Row type="flex">
                    <!-- <Col>
                        <CheckboxGroup @on-change="checkbox1">
                            <Checkbox label="电话"></Checkbox>
                        </CheckboxGroup>
                    </Col>
                    <Col>
                        <CheckboxGroup @on-change="checkbox2">
                            <Checkbox label="微信"></Checkbox>
                        </CheckboxGroup>
                    </Col> -->
                    <Col>
                        <CheckboxGroup @on-change="checkbox3">
                            <Checkbox label="重复"></Checkbox>
                        </CheckboxGroup>
                    </Col>
                </Row>
            </template>
        </jgsearch>
        <div class="i-table-no-border">
            <Table highlight-row :max-height="635" ref="table" :columns="columns" :data="list" :loading="loading"
                size="small" @on-sort-change="sortchange" @on-selection-change="selecttanle"
                @on-filter-change="handleFilterChange">
                <template slot-scope="{ row }" slot="info">
                    <a @click="handleDetailPatient(row)">{{ row.user_name }} {{ genderfun(row.gender) }}
                        {{ row.age }}岁</a>
                </template>
                <template slot-scope="{ row }" slot="state">
                    <Tag v-if="row.status_name === '失效'" color="blue">{{
                        row.status_name
                        }}</Tag>
                    <Tag v-else-if="row.status_name === '跟进中'" color="volcano">{{ row.status_name }}</Tag>
                    <Tag v-else-if="row.status_name === '预约'" color="cyan">{{
                        row.status_name
                        }}</Tag>
                    <Tag v-else-if="row.status_name === '到诊'" color="green">{{
                        row.status_name
                        }}</Tag>
                    <Tag v-else-if="row.status_name === '已到老患者'" color="orange">{{ row.status_name }}</Tag>
                    <Tag v-else-if="row.status_name" color="orange">{{
                        row.status_name
                        }}</Tag>
                </template>
                <template slot-scope="{ row }" slot="label">
                    <Poptip
                        word-wrap
                        trigger="hover"
                        placement="right"
                        width="400"
                    >
                        <template v-for="(item, index) in row.tags_name">
                            <Tag v-show="index<3" :color="item.type==1?'warning':'primary'" :key="index">{{ item.tags_name.replace(/[\r\n]/g, "") }}</Tag>
                        </template>
                        <div slot="content">
                            <template v-for="(item, index) in row.tags_name">
                                <Tag :color="item.type==1?'warning':'primary'" :key="index">{{ item.tags_name.replace(/[\r\n]/g, "") }}</Tag>
                            </template>
                        </div>
                    </Poptip>
                </template>
                <template slot-scope="{ row }" slot="channel">
                    <Badge v-if="row.source_name === 0" status="success" :text="row.source_name" />
                    <Badge v-if="row.source_name === 1" status="processing" :text="row.source_name" />
                    <Badge v-if="row.source_name === 2" status="error" :text="row.source_name" />
                    <Badge v-if="row.source_name === 3" status="warning" :text="row.source_name" />
                    <span>{{ row.source_name }}</span>
                </template>
                <template slot-scope="{ row }" slot="disease">
                    <span>{{
                        row.child_diseases_name || row.diseases_name
                        }}</span>
                </template>
                <template slot-scope="{ row, index }" slot="action">
                    <a v-hasC="{
                            name: 'patient-index-update4',
                            flag: 'v1/patient/index/update',
                        }" @click="handleOpenDrawer(row)">编辑</a>
                    <Divider type="vertical" v-if="+row.repeat_type > 0" v-hasC="{
                            name: 'v1-patient-index-repeat-list4',
                            flag: 'v1/patient/index/repeat-list',
                        }" />
                    <a @click="copypatient(row)" v-hasC="{
                            name: 'v1-patient-index-repeat-list4',
                            flag: 'v1/patient/index/repeat-list',
                        }" v-if="+row.repeat_type > 0">重复</a>
                    <Divider
                        type="vertical"
                        v-if="+row.is_delete === 1"
                        v-hasC="btnShows"
                    />
                    <a
                        @click="delpatient(row)"
                        v-hasC="btnShows"
                        style="color: red;"
                        v-if="+row.is_delete === 1"
                        >删除</a
                    >
                </template>
            </Table>
            <div class="ivu-mt iuv-text-center" slot="footer" style="text-align: center;">
                <Page show-total show-elevator show-sizer :total="total" :current.sync="params.page"
                    :page-size="params.pageSize" :page-size-opts="pageOpts" @on-change="changepage"
                    @on-page-size-change="changepageSize" />
            </div>
            <patient-detail ref="patientDetail" :btnShow="btnShow" @cancelDrawer="askData" @askData="askData" />
            <edit-patient ref="editPatient" @patientfun="askData" v-if="!loading" />
            <!-- <return-visit ref="returnVisit" /> -->
            <return-visit ref="returnVisit" @patientfuns="askData" />
        </div>
        <Modal v-model="modal" title="患者分配" @on-cancel="handleDrawerCancel">
            <!-- <Select v-model="formItem.allot_member_ids" filterable multiple>
        <Option
          v-for="item in userList"
          v-if="+item.status === 1"
          :value="item.value"
          :key="item.value"
          >{{ item.label }}</Option
        >
      </Select> -->
            <Select v-model="formItem.allot_member_ids" filterable multiple>
                <OptionGroup :label="item.label" v-for="item in userList" :key="item.value">
                    <Option v-if="+its.status === 1" v-for="its in item.children" :value="its.value" :key="its.value">{{
                        its.label }}</Option>
                </OptionGroup>
            </Select>
            <div slot="footer">
                <Button @click="handleDrawerCancel">取消</Button>
                <Button type="primary" :loading="remarksloading" :disabled="remarksloading"
                    @click="handleSubmit">确定</Button>
            </div>
        </Modal>
        <copymodal ref="copymodal" @askData="askData" :btnShow="btnShows" />
    </Card>
</template>
<script>
    import jgsearch from '@/components/search';
    import patientDetail from '@/components/patientDetail';
    import editPatient from '@/components/editPatient';
    import returnVisit from '@/components/returnVisit';
    import copymodal from '@/pages/patient/copymodal';
    import {
        patientindexfishlist,
        patientindexfishallot
    } from '@/api/hqapi/indexone.js';
    import { patientindexdelete, customerwechattagslist } from '@/api/hqapi';

    import tags from '@/components/tags';
    export default {
        name: 'fishPond',
        components: {
            jgsearch,
            patientDetail,
            editPatient,
            returnVisit,
            copymodal,
            tags
        },
        data () {
            return {
                btnShows: {
                    name: 'v1-patient-index-delete3',
                    flag: 'v1/patient/index/delete'
                },
                loading: false,
                btnShow: [
                    {
                        name: 'patient-index-sub6',
                        flag: 'v1/patient/index/sub'
                    },
                    {
                        name: 'patient-index-edit-remark6',
                        flag: 'v1/patient/index/edit-remark'
                    },
                    {
                        name: 'patient-index-update7',
                        flag: 'v1/patient/index/update'
                    },
                    {
                        name: 'patient-callback-callback-common-list2',
                        flag: 'v1/patient/callback/callback-common-list'
                    },
                    {
                        name: 'patient-index-edit-tags1',
                        flag: 'v1/patient/index/edit-tags'
                    },
                    {
                        name: 'patient-index-edit-tags11',
                        flag: 'v1/patient/index/edit-tags'
                    }
                ],
                remarksloading: false,
                searchData: {
                    project: [
                        {
                            id: 1,
                            key: 'DatePicker',
                            type: 'daterange',
                            style: { width: '200px' },
                            value: [new Date(), new Date()],
                            options: {
                                disabledDate (date) {
                                    return date && date.valueOf() > Date.now();
                                }
                            },
                            clearable: false,
                            placeholder: '请选择导入日期',
                            callback: 'change'
                        },
                        {
                            id: 2,
                            key: 'Input',
                            placeholder: '请输入患者姓名/手机号/微信号',
                            clearable: true,
                            style: { width: '220px' },
                            value: ''
                        },
                        { id: 21, key: 'Select', transfer: true, style: { minWidth: '100px' }, placeholder: '电话微信', value: '', childList: [{ label: '只有电话', value: 1 }, { label: '只有微信', value: 2 }, { label: '无联系方式', value: 3 }, { label: '有电话有微信', value: 4 }], clearable: true, callback: 'change' },
                        {
                            id: 3,
                            key: 'TreeSelect',
                            placeholder: '病种',
                            style: { width: '100px' },
                            clearable: true,
                            value: '',
                            childList: [],
                            callback: 'change'
                        },
                        {
                            id: 4,
                            key: 'Select',
                            placeholder: '患者状态',
                            style: { width: '100px' },
                            clearable: true,
                            value: '',
                            field: { value: 'id', label: 'status_name' },
                            childList: [],
                            callback: 'change'
                        },
                        {
                            id: 12,
                            key: 'Select',
                            placeholder: '上次回访人',
                            style: { width: '140px' },
                            clearable: true,
                            value: '',
                            childList: [],
                            callback: 'change'
                        },

                        // {
                        //     id: 7,
                        //     key: "Select",
                        //     placeholder: "选择部门",
                        //     clearable: true,
                        //     value: "",
                        //     childList: [],
                        //     callback: "changes",
                        // },
                        // {
                        //     id: 6,
                        //     key: "Select",
                        //     placeholder: "上次归属人",
                        //     style: { width: "150px" },
                        //     clearable: true,
                        //     Group: true,
                        //     value: "",
                        //     childList: [],
                        //     callback: "change",
                        // },
                        {
                            id: 6,
                            key: 'slot',
                            keys: 'select'
                        },
                        // {
                        //     id: 5,
                        //     key: "Selects",
                        //     field: { label:'tag_name',value: 'tag_id'}, placeholder: '请先选择归属人再选择标签', clearable: true, value: [], childList: [], filterable: true, multiple: true, maxTagCount: 3, callback: 'changess'
                        // },
                        { id: 30, key: 'slot', keys: 'tag' },
                        { id: 8, key: 'slot', keys: 'addcheck' },
                        { id: 31, key: 'Button', label: '搜索', callback: 'subclick' }
                    ],
                    button: [
                        {
                            key: '分配',
                            has: {
                                name: 'patient-index-fish-allot2',
                                flag: 'v1/patient/index/fish-allot'
                            }
                        }
                    ]
                },
                showkey: false,
                columns: [
                    { type: 'selection', fixed: 'left', width: 55 },
                    {
                        title: '基本信息',
                        key: 'basic',
                        slot: 'info',
                        width: 180,
                        fixed: 'left'
                    },
                    // { title: '微信号', key: 'wx', width: 108 },
                    { title: '患者状态', key: 'state', slot: 'state', width: 100 },
                    { title: '上次归属人', key: 'realname', width: 118 },
                    {
                        title: '导入时间',
                        key: 'export_time_str',
                        sortable: 'custom',
                        width: 108
                    },
                    {
                        title: '回访次数',
                        key: 'callback_count',
                        sortable: 'custom',
                        width: 108
                    },
                    {
                        title: '上次回访人',
                        key: 'last_callback_realname',
                        width: 108
                    },
                    {
                        title: '未访天数',
                        key: 'uncallback_day',
                        sortable: 'custom',
                        filters: [
                            {
                                label: '0-10天未访',
                                value: '1'
                            },
                            {
                                label: '11-20天未访',
                                value: '2'
                            },
                            {
                                label: '21-30天未访',
                                value: '3'
                            },
                            {
                                label: '31-60天未访',
                                value: '4'
                            },
                            {
                                label: '60天以上未访',
                                value: '5'
                            }
                        ],
                        filterMultiple: false,
                        filterRemote (value) {
                            this.filterType = value[0];
                        },
                        width: 118
                    },
                    { title: '患者标签', key: 'label', slot: 'label', width: 260 },
                    { title: '城市', key: 'city_name', width: 200 },
                    { title: '病种', slot: 'disease', width: 200 },
                    {
                        title: '来源',
                        width: 260,
                        slot: 'channel',
                        ellipsis: true,
                        tooltip: true
                    },
                    // { title: '创建时间', key: 'foundTime', width: 135 },
                    {
                        title: '备注',
                        minWidth: 250,
                        key: 'remark',
                        ellipsis: true,
                        tooltip: true
                    },
                    { title: '操作', width: 160, slot: 'action', fixed: 'right' }
                ],
                total: 0,
                pageOpts: [10, 15, 20, 30, 50],
                params: {
                    page: 1,
                    pageSize: 10,
                    export_stime: new Date(),
                    export_etime: new Date(),
                    keywords: '',
                    patient_diseases_id: '',
                    patient_status_id: '',
                    tags_ids: '',
                    project_tags_ids: '',
                    have_wechat: 0,
                    have_mobile: 0,
                    have_repeat: 0,
                    last_callback_id: '',
                    belong_member_id: '',
                    department_id: '',
                    sort_export_time: '',
                    sort_callback_count: '',
                    sort_last_callback_time: '',
                    not_callback_start: '',
                    have_contact_type: '',
                    not_callback_end: ''
                },
                condition: {},
                realnamebool: true,
                userList: [],
                formItem: { allot_member_ids: [], allot_ids: '' },
                modal: false,
                member_list_list: [],
                list: [],
                member_list: []
            };
        },
        mounted () {
            this.initial();
        },
        methods: {
            sunchangetag (e) {
                // this.params.page = 1
                this.params.tags_ids = e.tags_ids
                this.params.project_tags_ids = e.project_tags_ids
                // this.askData()
            },
            changetag (member_id = '') {
                customerwechattagslist({ member_id }).then(res => {
                    this.searchData.project.forEach(item => {
                        if (item.id === 5) {
                            item.value = []
                            item.childList = res.list
                        }
                    })
                    // this.askData()
                })
            },
            copypatient (row) {
                this.$refs.copymodal.initial(row.id);
            },
            initial () {
                let attr_list = JSON.parse(
                    window.localStorage.getItem('attr_list')
                );
                let ProjectId = window.localStorage.getItem('currentProject');
                for (let item of attr_list) {
                    if (+item.project_id === +ProjectId) {
                        this.searchData.project.forEach((items) => {
                            if (items.id === 7) {
                                items.value = item.department_id;
                                this.params.department_id = item.department_id;
                            }
                        });
                    }
                }
                this.askData();
            },
            delpatient (row) {
                this.$Modal.confirm({
                    title: '删除确认',
                    content: `<p>删除后患者进入回收站，将不在其他列表展示</p>`,
                    loading: true,
                    onOk: () => {
                        patientindexdelete({ id: row.id }).then(() => {
                            this.$Message.info('删除成功');
                            this.askData();
                            this.$Modal.remove()
                        });
                    }
                });
            },
            askData () {
                this.loading = true;
                this.formItem = { allot_member_ids: [], allot_ids: '' };
                patientindexfishlist(this.params).then((res) => {
                    this.member_list = res.condition.member_list;
                    this.total = res.total;
                    this.list = res.list;
                    this.userList = res.condition.allot_member_list;
                    this.searchData.project.forEach((item) => {
                        if (item.id === 3) {
                            if (item.childList.length === 0) { item.childList = res.condition.diseases; }
                        } else if (item.id === 4) {
                            if (item.childList.length === 0) { item.childList = res.condition.status_list; }
                        }
                        // else if (item.id === 6) {
                        //     if (item.childList.length === 0)
                        //         item.childList = res.condition.member_list;
                        // }
                        else if (item.id === 12) {
                            if (item.childList.length === 0) { item.childList = res.condition.last_callback_list; }
                        } else if (item.id === 7) {
                            if (item.childList.length === 0) {
                                item.childList = res.condition.department_list;
                                // if (res.condition.department_list.length === 1) {
                                //     this.member_list_list =
                                //         res.condition.department_list;
                                // }
                            }
                            // if (res.condition.member_list.length === 1)
                            //     item.value = res.condition.member_list[0].value;
                        }
                    });
                    this.member_list_list = res.condition.member_list;
                    // if (this.params.department_id) {
                    //     this.member_list_list = [];
                    //     for (let its in this.member_list) {
                    //         if (
                    //             this.params.department_id ===
                    //             this.member_list[its].value
                    //         ) {
                    //             this.member_list_list = [this.member_list[its]];
                    //             this.showkey = true;
                    //         }
                    //     }
                    // } else if (!this.params.department_id) {
                    //     this.showkey = false;
                    // }
                    this.loading = false;
                });
            },
            /* @函数功能: 分页 */
            changepage (e) {
                this.params.page = e;
                this.askData();
            },
            /* @函数功能: 每页数量 */
            changepageSize (e) {
                this.params.pageSize = e;
                this.askData();
            },
            askDatasearch () {
                // this.params = {
                //     page: 1,
                //     pageSize: 10,
                //     export_stime: '',
                //     have_wechat: 0,
                //     have_mobile: 0,
                //     have_repeat: 0,
                //     export_etime: '',
                //     keywords: '',
                //     patient_diseases_id: '',
                //     patient_status_id: '',
                //     last_callback_id: '',
                //     tags_ids: '',
                //     project_tags_ids: '',
                //     belong_member_id: '',
                //     sort_export_time: '',
                //     sort_callback_count: '',
                //     sort_last_callback_time: '',
                //     not_callback_start: '',
                //     have_contact_type: '',
                //     not_callback_end: ''
                // };
                this.searchData.project.forEach((item) => {
                    if (item.id === 2) {
                        this.params.keywords = item.value;
                    } else if (item.id === 1) {
                        let keywording = '';
                        this.searchData.project.forEach((items) => {
                            if (items.id === 2) {
                                keywording = items.value;
                            }
                        });
                        if (keywording !== '') {
                            if (
                                JSON.stringify(item.value) !==
                                JSON.stringify(['', ''])
                            ) {
                                let timer = [
                                    this.$Date(item.value[0]).format('YYYY-MM-DD'),
                                    this.$Date(item.value[1]).format('YYYY-MM-DD')
                                ];
                                this.storage.set('fishPond', timer);
                                item.value = ['', ''];
                                this.params.export_stime = '';
                                this.params.export_etime = '';
                            }
                        } else {
                            if (
                                JSON.stringify(this.storage.get('fishPond')) !==
                                JSON.stringify(['', ''])
                            ) {
                                item.value = this.storage.get('fishPond');
                                this.params.export_stime = item.value[0];
                                this.params.export_etime = item.value[1];
                            }
                        }
                    }
                    // else if (item.id === 3) {
                    //     item.value = '';
                    // } else if (item.id === 4) {
                    //     item.value = '';
                    // } else if (item.id === 5) {
                    //     item.value = [];
                    //     item.childList = [];
                    // }
                    // // else if (item.id === 6) {
                    // //     item.value = "";
                    // // }
                    // else if (item.id === 7) {
                    //     item.value = '';
                    // } else if (item.id === 21) {
                    //     item.value = '';
                    // }
                });
                this.showkey = false;
                // this.askData();
            },
            askDatachanges () {
                // this.params.page = 1;
                this.searchData.project.forEach((item) => {
                    if (item.id === 1) {
                        this.params.export_stime = item.value[0];
                        this.params.export_etime = item.value[1];
                        let timer = ['', ''];
                        if (
                            JSON.stringify(item.value) !== JSON.stringify(['', ''])
                        ) {
                            timer = [
                                this.$Date(item.value[0]).format('YYYY-MM-DD'),
                                this.$Date(item.value[1]).format('YYYY-MM-DD')
                            ];
                        }
                        this.storage.set('fishPond', timer);
                    } else if (item.id === 3) {
                        this.params.patient_diseases_id = item.value;
                    } else if (item.id === 4) {
                        this.params.patient_status_id = item.value;
                    } else if (item.id === 12) {
                        this.params.last_callback_id = item.value;
                    }
                    // else if (item.id === 6) {
                    //     this.params.belong_member_id = item.value;
                    // }
                    else if (item.id === 7) {
                        this.params.department_id = item.value;
                    } else if (item.id === 21) {
                        this.params.have_contact_type = item.value;
                    }
                });
                // this.askData();
            },
            askDatachangeing () {
                // this.params.page = 1;
                this.searchData.project.forEach((item) => {
                    if (item.id === 1) {
                        this.params.export_stime = item.value[0];
                        this.params.export_etime = item.value[1];
                        let timer = ['', ''];
                        if (
                            JSON.stringify(item.value) !== JSON.stringify(['', ''])
                        ) {
                            timer = [
                                this.$Date(item.value[0]).format('YYYY-MM-DD'),
                                this.$Date(item.value[1]).format('YYYY-MM-DD')
                            ];
                        }
                        this.storage.set('fishPond', timer);
                    } else if (item.id === 3) {
                        this.params.patient_diseases_id = item.value;
                    } else if (item.id === 4) {
                        this.params.patient_status_id = item.value;
                    } else if (item.id === 12) {
                        this.params.last_callback_id = item.value;
                    }
                    // else if (item.id === 6) {
                    //     this.params.belong_member_id = item.value;
                    // }
                    else if (item.id === 7) {
                        this.params.department_id = item.value;
                    }
                });
                this.changetag(this.params.belong_member_id ? this.params.belong_member_id : undefined)
            },
            askDatachangess () {
                // this.params.page = 1;
                this.searchData.project.forEach((item) => {
                    if (item.id === 5) {
                        this.params.tags_ids = item.value.join(',');
                    }
                });
                // this.askData();
            },
            askDataclick () {
                if (!this.realnamebool) { return this.$Message.error('上次归属人不一致，请重新选择'); }
                if (this.formItem.allot_ids === '') { return this.$Message.error('请选择患者'); }
                this.modal = true;
            },
            sortchange (e) {
                if (e.key === 'export_time_str') {
                    if (e.order === 'desc') {
                        this.params.sort_export_time = 2;
                    } else if (e.order === 'asc') {
                        this.params.sort_export_time = 1;
                    } else {
                        this.params.sort_export_time = 0;
                    }
                    this.params.sort_callback_count = 0;
                    this.params.sort_last_callback_time = 0;
                } else if (e.key === 'callback_count') {
                    if (e.order === 'desc') {
                        this.params.sort_callback_count = 2;
                    } else if (e.order === 'asc') {
                        this.params.sort_callback_count = 1;
                    } else {
                        this.params.sort_callback_count = 0;
                    }
                    this.params.sort_export_time = 0;
                    this.params.sort_last_callback_time = 0;
                } else {
                    if (e.order === 'desc') {
                        this.params.sort_last_callback_time = 2;
                    } else if (e.order === 'asc') {
                        this.params.sort_last_callback_time = 1;
                    } else {
                        this.params.sort_last_callback_time = 0;
                    }
                    this.params.sort_export_time = 0;
                    this.params.sort_callback_count = 0;
                }
                this.askData();
            },
            genderfun (type) {
                let gender = '';
                if (+type === 0) gender = '未知';
                else if (+type === 1) gender = '男';
                else if (+type === 2) gender = '女';
                return gender;
            },
            handleOpenDrawer (row) {
                if (row === -1) this.$refs.editPatient.handleOpenDrawer();
                else this.$refs.editPatient.handleEdit(row, true);
            },
            handleDetailPatient (row) {
                this.$refs.patientDetail.handleOpen(row, true);
            },
            selecttanle (e) {
                let list = [];
                let realnametext = '';
                if (e.length > 0) realnametext = e[0].realname;
                this.realnamebool = true;
                for (let item of e) {
                    list.push(item.id);
                    if (this.realnamebool) { this.realnamebool = realnametext === item.realname; }
                }
                this.formItem.allot_ids = list.join(',');
            },
            handleSubmit () {
                this.remarksloading = true;
                let config = {
                    allot_member_ids: this.formItem.allot_member_ids.join(','),
                    allot_ids: this.formItem.allot_ids
                };
                patientindexfishallot(config)
                    .then(() => {
                        this.modal = false;
                        this.$Message.success('分配成功');
                        this.askData();
                        setTimeout(() => {
                            this.remarksloading = false;
                        }, 500);
                    })
                    .catch(() => {
                        this.remarksloading = false;
                });
            },
            handleDrawerCancel () {
                // this.formItem = { allot_member_ids: [], allot_ids: "" }
                this.modal = false;
            },
            askDatachange () {
                this.params.page = 1;
                // this.params.belong_member_id = "";
                this.searchData.project.forEach((item) => {
                    if (item.id === 1) {
                        this.params.export_stime = item.value[0];
                        this.params.export_etime = item.value[1];
                    } else if (item.id === 3) {
                        this.params.patient_diseases_id = item.value;
                    } else if (item.id === 4) {
                        this.params.patient_status_id = item.value;
                    }
                    //  else if (item.id === 6) {
                    //     this.params.belong_member_id = item.value;
                    // }
                    else if (item.id === 7) {
                        this.params.department_id = item.value;
                    }
                });
                // if (this.params.department_id) {
                //     this.member_list_list = [];
                //     for (let its in this.member_list) {
                //         if (
                //             this.params.department_id ===
                //             this.member_list[its].value
                //         ) {
                //             this.member_list_list = [this.member_list[its]];
                //             this.showkey = true;
                //         }
                //     }
                // } else if (!this.params.department_id) {
                //     this.showkey = false;
                // }
                this.askData();
            },
            checkbox1 (e) {
                this.params.page = 1;
                this.params.have_mobile = e.length;
                this.searchData.project.forEach((item) => {
                    if (item.id === 1) {
                        item.value = ['', ''];
                        this.params.export_stime = '';
                        this.params.export_etime = '';
                    }
                });
                this.askData();
            },
            checkbox2 (e) {
                this.params.page = 1;
                this.params.have_wechat = e.length;
                this.searchData.project.forEach((item) => {
                    if (item.id === 1) {
                        item.value = ['', ''];
                        this.params.export_stime = '';
                        this.params.export_etime = '';
                    }
                });
                this.askData();
            },
            checkbox3 (e) {
                // this.params.page = 1;
                this.params.have_repeat = e.length;
                // this.searchData.project.forEach((item) => {
                //     if (item.id === 1) {
                //         item.value = ['', ''];
                //         this.params.export_stime = '';
                //         this.params.export_etime = '';
                //     }
                // });
                // this.askData();
            },
            handleFilterChange (value) {
                let params = {
                    not_callback_start: '',
                    not_callback_end: this.$Date().format('YYYY-MM-DD')
                };
                if (+value._filterChecked[0] === 1) {
                    params.not_callback_start = this.$Date()
                        .subtract(10, 'day')
                        .format('YYYY-MM-DD');

                    params.not_callback_end = this.$Date().format('YYYY-MM-DD');
                } else if (+value._filterChecked[0] === 2) {
                    params.not_callback_start = this.$Date()
                        .subtract(20, 'day')
                        .format('YYYY-MM-DD');

                    params.not_callback_end = this.$Date()
                        .subtract(11, 'day')
                        .format('YYYY-MM-DD');
                } else if (+value._filterChecked[0] === 3) {
                    params.not_callback_start = this.$Date()
                        .subtract(30, 'day')
                        .format('YYYY-MM-DD');

                    params.not_callback_end = this.$Date()
                        .subtract(21, 'day')
                        .format('YYYY-MM-DD');
                } else if (+value._filterChecked[0] === 4) {
                    params.not_callback_start = this.$Date()
                        .subtract(60, 'day')
                        .format('YYYY-MM-DD');

                    params.not_callback_end = this.$Date()
                        .subtract(31, 'day')
                        .format('YYYY-MM-DD');
                } else if (+value._filterChecked[0] === 5) {
                    params.not_callback_start = '';
                    params.not_callback_end = this.$Date()
                        .subtract(61, 'day')
                        .format('YYYY-MM-DD');
                } else {
                    params.not_callback_start = '';
                    params.not_callback_end = '';
                }
                this.params.page = 1;
                this.params.not_callback_end = params.not_callback_end;
                this.params.not_callback_start = params.not_callback_start;
                this.askData();
            },
            subclick () {
                this.params.page = 1;
                this.askData();
            }
        }
    };
</script>
